package com.sinog.core.util;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @desc 集合处理工具类
 * @author lzq
 * @date 2020-08-31 6:58 下午
 */
public final class CollectionUtils {

    /**
     * 描述
     * @param list 原有list
     * @param num list至少含有个数
     * @return List<Map < String,Object>>
     */
    public static List<Map<String,Object>> fillList(List<Map<String,Object>> list,int num) {
        if(null == list) {
            list = new ArrayList<>(16);
        }
        Map<String,Object> map = new HashMap<>(16);
        if(list.size() < num) {
            for(int i = list.size(); i < num; i++) {
                list.add(map);
            }
        }
        return list;
    }

    /**
     * 判断集合为非空
     * @param collection 传入collection集合
     * @return boolean
     */
    public static boolean isNotEmpty(Collection<?> collection) {
        return (null != collection && !collection.isEmpty());
    }
}